package com.tds.springbootdemo2.controller;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.thread.ThreadUtil;
import com.tds.springbootdemo2.vo.AjaxResult;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * Copyright (C) 2014-2023 天津紫藤科技有限公司. Co. Ltd. All Rights Reserved.
 *
 * @author tongdashuai
 * @version 1.0
 * @description
 * @module
 * @date 2025/1/22 9:53
 */
@RestController("/test")
@RequestMapping("/test")
public class TestController {


    @GetMapping("/test1")
    public AjaxResult test1() {
        System.out.println("test1---" + Thread.currentThread().getName());
        List<String> list = CollUtil.newArrayList("1", "2", "3", "4");
        list.parallelStream().forEach(item -> {
            System.out.println(item + "---" + Thread.currentThread().getName());
            ThreadUtil.sleep(1000 * 60 * 60);
        });
        return AjaxResult.success();
    }

    @GetMapping("/test2")
    public AjaxResult test2() {

        System.out.println("test2---" + Thread.currentThread().getName());
        ThreadUtil.sleep(1000 * 60);
        return AjaxResult.success();
    }

    @PostMapping("/test3")
    @CrossOrigin
    public AjaxResult test3(MultipartFile file) {
        System.out.println("文件原始名称：" + file.getOriginalFilename());
        return AjaxResult.success();
    }
}
